package org.ushio.nchu_22201404.dao;

import org.apache.ibatis.annotations.*;
import org.ushio.common_module.entity.CustomerServiceRecord;

import java.util.List;

@Mapper
public interface ServiceOnlineRecordDao {
    @Insert("INSERT INTO customer_service_record (Conversation_Content, Conversation_Start_Time, Conversation_End_Time, Rating, Complaint, Phone_Number, Customer_Service_ID)" +
            "VALUES (#{conversationContent}, '2024-11-13', '2024-11-13', 0, 0, #{phoneNumber}, 1)")
    @Options(useGeneratedKeys = true, keyProperty = "serviceRecordId")
    void serviceOnlineRecordInsert(CustomerServiceRecord customerServiceRecord);

    @Select("SELECT Conversation_Content, Phone_Number FROM customer_service_record")
    @Results({
            @Result(property = "conversationContent", column = "Conversation_Content"),
            @Result(property = "phoneNumber", column = "Phone_Number")
    })
    List<CustomerServiceRecord> getServiceOnlineRecordToCustomerService();

    @Select("SELECT * FROM customer_service_record")
    @Results({
            @Result(property = "serviceRecordId", column = "Service_Record_ID"),
            @Result(property = "conversationContent", column = "Conversation_Content"),
            @Result(property = "conversationStartTime", column = "Conversation_Start_Time"),
            @Result(property = "conversationEndTime", column = "Conversation_End_Time"),
            @Result(property = "rating", column = "Rating"),
            @Result(property = "complaint", column = "Complaint"),
            @Result(property = "phoneNumber", column = "Phone_Number"),
            @Result(property = "customerServiceId", column = "Customer_Service_ID")
    })
    List<CustomerServiceRecord> getServiceOnlineRecordToAdmin();

    @Select("SELECT * FROM customer_service_record WHERE Phone_Number = #{phoneNumber}")
    @Results({
            @Result(property = "serviceRecordId", column = "Service_Record_ID"),
            @Result(property = "conversationContent", column = "Conversation_Content"),
            @Result(property = "conversationStartTime", column = "Conversation_Start_Time"),
            @Result(property = "conversationEndTime", column = "Conversation_End_Time"),
            @Result(property = "rating", column = "Rating"),
            @Result(property = "complaint", column = "Complaint"),
            @Result(property = "phoneNumber", column = "Phone_Number"),
            @Result(property = "customerServiceId", column = "Customer_Service_ID")
    })
    List<CustomerServiceRecord> getServiceOnlineRecordByPhoneNumber(@Param("phoneNumber") String phoneNumber);
}
